package com.by.controller;

import com.by.constant.MessageConstant;
import com.by.entity.Result;
import com.by.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    /**
    * @Description: 提交预约信息
            * @Param: * @param map
            * @return: com.by.entity.Result
            * @Author: GP
            * @Date: 2024/1/14
            */
    @RequestMapping("/submit")
    public Result submit(@RequestBody Map map){
        try {
           return orderService.submit(map);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.ORDER_FAIL);
        }
    }


    /**
    * @Description: 查询预约信息
            * @Param: * @param id
            * @return: com.by.entity.Result
            * @Author: GP
            * @Date: 2024/1/14
            */
    @RequestMapping("/findById")
    public Result findById(Integer id){
        try {
            Map map = orderService.findById(id);
            return new Result(true, MessageConstant.QUERY_ORDER_SUCCESS, map);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.QUERY_ORDER_FAIL);
        }

    }
}
